<?php
function blog_theme_select($action='',$name='',$value='') {
    $option=array('1','2','3','4','5','6','7','8');
    if($action=='output') {
        echo('<select name="'.$name.'">');
        foreach($option as $val) {
            if($value==$val) {
                echo('<option value="'.$val.'" selected>'.$val.'</option>');
            }else {
                echo('<option value="'.$val.'">'.$val.'</option>');
            }
        }
        echo('</select>');
    }
    if($action=='input') {
        if(isset($_POST[$name]) && in_array($_POST[$name],$option)) {
            Return $_POST[$name];
        }
        Return '';
    }
    if($action=='show') {
        Return $value;
    }
    return '';
}

function blog_art_modify($action='',$name='',$value='') {
    if($action=='output') {
        $now=now_str();
        echo <<<HTML
<input type="text" class="inputtext" value="{$now}" name="{$name}" /> <span>上次修改时间：{$value}</span>
HTML;
    }
    if($action=='input') {
        if(isset($_POST[$name])) {
            Return now_str();
        }
        Return '';
    }
    if($action=='show') {
        Return $value;
    }
    return '';
}
//获取文章的作者
function getnickname($id)
{
    global $usernicknames;
    if (!$usernicknames){
        $admin_table_name=tableex('admin');
        $usernicknames = M()->all_assoc("SELECT id,nickname FROM {$admin_table_name}");
//        echo 'getnickname';
    }
    foreach ($usernicknames as $item) {
        if ($item['id'] == $id) {
            return $item['nickname'];
        }
    }
    return '未知';
}